//
//  ScanZhuangXiangCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/11/12.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "ScanZhuangXiangCell.h"

@interface ScanZhuangXiangCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *NOLab;
@property (nonatomic, strong) UILabel *modelTitleLab;
@property (nonatomic, strong) UILabel *modelLab;
@property (nonatomic, strong) UILabel *sizeTitleLab;
@property (nonatomic, strong) UILabel *sizeLab;
@property (nonatomic, strong) UILabel *linkTitleLab;
@property (nonatomic, strong) UILabel *linkLab;

@end

@implementation ScanZhuangXiangCell

+ (instancetype)ScanZhuangXiangCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"ScanZhuangXiangCell";
    ScanZhuangXiangCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ScanZhuangXiangCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 10, ScreenW - 30, 136)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.NOLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 20, self.bgView.nim_width - 30, 21)];
        self.NOLab.font = BoldFontOfSize(20);
        self.NOLab.textColor = Color_ThemeColor;
        [self.bgView addSubview:self.NOLab];
        
        self.modelTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(self.NOLab.nim_left, 10 + self.NOLab.nim_bottom, (self.bgView.nim_width - 30) * 0.3, 15)];
        self.modelTitleLab.font = [UIFont systemFontOfSize:14];
        self.modelTitleLab.textColor = HexColor(0x9C9DB3);
        [self.bgView addSubview:self.modelTitleLab];
        
        self.modelLab = [[UILabel alloc] initWithFrame:CGRectMake(self.modelTitleLab.nim_right, self.modelTitleLab.nim_top, (self.bgView.nim_width - 30) * 0.7, 15)];
        self.modelLab.font = [UIFont systemFontOfSize:14];
        self.modelLab.textColor = HexColor(0x2B2C44);
        self.modelLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.modelLab];
        
        self.sizeTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(self.NOLab.nim_left, 10 + self.modelTitleLab.nim_bottom, (self.bgView.nim_width - 30) * 0.3, 15)];
        self.sizeTitleLab.font = [UIFont systemFontOfSize:14];
        self.sizeTitleLab.textColor = HexColor(0x9C9DB3);
        [self.bgView addSubview:self.sizeTitleLab];
        
        self.sizeLab = [[UILabel alloc] initWithFrame:CGRectMake(self.sizeTitleLab.nim_right, self.sizeTitleLab.nim_top, (self.bgView.nim_width - 30) * 0.7, 15)];
        self.sizeLab.font = [UIFont systemFontOfSize:14];
        self.sizeLab.textColor = HexColor(0x2B2C44);
        self.sizeLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.sizeLab];
        
        self.linkTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(self.NOLab.nim_left, 10 + self.sizeTitleLab.nim_bottom, (self.bgView.nim_width - 30) * 0.3, 15)];
        self.linkTitleLab.font = [UIFont systemFontOfSize:14];
        self.linkTitleLab.textColor = HexColor(0x9C9DB3);
        [self.bgView addSubview:self.linkTitleLab];
        
        self.linkLab = [[UILabel alloc] initWithFrame:CGRectMake(self.linkTitleLab.nim_right, self.linkTitleLab.nim_top, (self.bgView.nim_width - 30) * 0.7, 15)];
        self.linkLab.font = [UIFont systemFontOfSize:14];
        self.linkLab.textColor = HexColor(0x2B2C44);
        self.linkLab.textAlignment = NSTextAlignmentRight;
        [self.bgView addSubview:self.linkLab];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setModel:(ScanZhuangXiangModel *)model {
    _model = model;
    if (model.rv_num.length) {
        //周转箱
        self.NOLab.text = model.rv_num;
        
        self.modelTitleLab.text = @"型号：";
        self.modelLab.text = model.model;
        self.sizeTitleLab.text = @"尺寸：";
        self.sizeLab.text = model.size;
        self.linkTitleLab.text = @"关联设备：";
        self.linkLab.text = self.model.fuselage;
    }else if (model.pk_num.length) {
        //普通包装
        self.NOLab.text = model.pk_num;
        
        self.modelTitleLab.text = @"包装名称：";
        self.modelLab.text = model.name;
        self.sizeTitleLab.text = @"型号：";
        self.sizeLab.text = model.model;
        self.linkTitleLab.text = @"尺寸：";
        self.linkLab.text = model.size;
    }
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
